using System;
using UnityEngine;
using UnityEngine.UIElements;
using DG.Tweening;

public class FadePanel : MonoBehaviour
{
   private VisualElement backGround;
   private void Awake()
   {
      backGround = GetComponent<UIDocument>().rootVisualElement.Q<VisualElement>("BackGround");
   }

   public void FadeIn(float duration)
   {
      DOVirtual.Float(0, 1, duration, (value) =>
      {
         backGround.style.opacity = value;
      }).SetEase(Ease.InQuad);
   }
   
   public void FadeOut(float duration)
   {
      DOVirtual.Float(1, 0, duration, (value) =>
      {
         backGround.style.opacity = value;
      }).SetEase(Ease.InQuad);
   }
}
